package com.example.sneakerappserver.repository;

import com.example.sneakerappserver.pojo.User;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository // spring bean
public interface UserRepository extends CrudRepository<User,Integer> {

    @Query(value = "SELECT * FROM tb_user WHERE user_id=:userId", nativeQuery = true)
    User findByUserId(long userId); // 根据Id进行查询

    @Query(value = "SELECT * FROM tb_user WHERE user_name=:userName", nativeQuery = true)
    User findByUserName(String userName); // 根据Id进行查询
}
